package com.xiaodong.j20240319;

import com.xiaodong.j20240319.component.UserComponent;
import com.xiaodong.j20240319.config.UserConfig;
import com.xiaodong.j20240319.controller.UserController;

import com.xiaodong.j20240319.model.UserInfo;
import com.xiaodong.j20240319.repo.UserRepository;
import com.xiaodong.j20240319.service.UserService;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;


@SpringBootApplication
public class IocDemoApplication {
    //被这个注解标识的就叫做启动类
//对象管理容器
    public static void main(String[] args) {
        ApplicationContext context =  SpringApplication.run(IocDemoApplication.class,args);
        UserController bean = context.getBean(UserController.class);
        bean.sayHi();

        UserService userService = (UserService) context.getBean("userService");
        userService.sayHi();

        UserComponent userComponent = context.getBean("userComponent", UserComponent.class);
        userComponent.sayHi();

        UserRepository userRepository = (UserRepository) context.getBean("userRepository");
        userRepository.sayHi();

        UserConfig userConfig = context.getBean(UserConfig.class);
        userConfig.sayHi();

        UserInfo userInfo = context.getBean("userInfo2",UserInfo.class);
        System.out.println(userInfo);
    }

    //和操作系统中的上下文这个概念有关系。
    //


}

